Skip to content

feat(client-core): add signal option to support abort fetch #9539

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
May 16, 2025

Conversation

woai3c
Copy link
Contributor

@woai3c woai3c commented May 2, 2025

Check List

  • Tests have been run in packages where changes made if available
  • Linter has been run for changed code
  • Tests for the changes have been added if not covered yet
  • Docs have been added / updated if required

Description of Changes Made

This PR adds the ability to abort requests in @cubejs-client/core by introducing support for the AbortController signal. The implementation:

  1. Extends the HttpTransport constructor and request method to accept a signal parameter
  2. Adds signal support to CubeApi's constructor and all request methods (load, meta, sql, dryRun)
  3. Implements priority handling where method-specific signals override constructor signals
  4. Adds comprehensive test coverage for all signal-related functionality

These changes allow users to cancel in-flight requests by using the AbortController API:

// Example usage
const controller = new AbortController();
const { signal } = controller;

// Pass signal in constructor (affects all requests)
const cubeApi = new CubeApi('token', {
  apiUrl: '...',
  signal
});

// Or pass signal to specific methods
const resultSet = await cubeApi.load(query, { signal });

// To abort the request at any time
controller.abort();

@woai3c woai3c requested a review from a team as a code owner May 2, 2025 09:53
@github-actions github-actions bot added the pr:community Contribution from Cube.js community members. label May 2, 2025
@KSDaemon KSDaemon self-assigned this May 15, 2025
@ovr ovr requested a review from vasilev-alex May 15, 2025 15:26
Copy link

codecov bot commented May 15, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 57.50%. Comparing base (8cc6346) to head (4042eab).
Report is 34 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #9539   +/-   ##
=======================================
  Coverage   57.50%   57.50%           
=======================================
  Files         165      165           
  Lines       13504    13504           
  Branches     2278     2278           
=======================================
  Hits         7766     7766           
  Misses       5430     5430           
  Partials      308      308           
Flag Coverage Δ
cube-backend 57.50% <ø> (ø)

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Member

@KSDaemon KSDaemon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@woai3c Great! Thank you for your contribution!

@KSDaemon KSDaemon merged commit 2536dfc into cube-js:master May 16, 2025
29 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
pr:community Contribution from Cube.js community members.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants